#include<bits/stdc++.h>
using namespace std;
#define ll long long

class Solution {
public:
    int reinitializePermutation(int n) {
        vector<int> prem(n);
        for (int i = 0; i < n; i++) {
            prem[i] = i;
        }
        vector<int> arr = prem;
        vector<int> vec = prem;
        int cnt = 1;
        while (1) {
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    arr[i] = prem[i / 2];
                } else {
                    arr[i] = prem[n / 2 + (i - 1) / 2];
                }
            }
            prem = arr;
            if (vec == arr) return cnt;
            cnt++;
        }
        return cnt;
    }
};

int stringToInteger(string input) {
    return stoi(input);
}

int main() {
    string line;
    while (getline(cin, line)) {
        int n = stringToInteger(line);
        
        int ret = Solution().reinitializePermutation(n);

        string out = to_string(ret);
        cout << out << endl;
    }
    return 0;
}